<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//
// ===============================================================================
// Add-On: All Invoices v1.0
// Designed for: Zen Cart 1.3.x series
// Created by: Mathew O'Marah (www.mdodesign.co.uk)
//
// Donations:  Please support Zen Cart!  paypal@zen-cart.com  - Thank you!
// ===============================================================================
require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

include(DIR_WS_CLASSES . 'order.php');
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title>Daily Report</title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
  <!--
  function init()
  {
    cssjsmenu('navbar');
    if (document.getElementById)
    {
      var kill = document.getElementById('hoverJS');
      kill.disabled = true;
    }
  }
  // -->
</script>
</head>
<body onLoad="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<?php
global $db;

$orders_ctt = $db->Execute("select o.orders_id, t.text, t.value
                               from " . TABLE_ORDERS . " o 
								join " . TABLE_ORDERS_TOTAL . " t on o.orders_id = t.orders_id
                               where t.class = 'ot_total' and o.orders_status = '2' and o.payment_module_code = 'cod' and o.shipping_module_code = 'table5'");
$orders_nacex = $db->Execute("select o.orders_id, t.text, t.value
                               from " . TABLE_ORDERS . " o 
								join " . TABLE_ORDERS_TOTAL . " t on o.orders_id = t.orders_id
                               where t.class = 'ot_total' and orders_status = '2' and o.payment_module_code = 'cod' and o.shipping_module_code = 'table4'");
$orders_seur = $db->Execute("select o.orders_id, t.text, t.value
                               from " . TABLE_ORDERS . " o 
								join " . TABLE_ORDERS_TOTAL . " t on o.orders_id = t.orders_id
                               where t.class = 'ot_total' and orders_status = '2' and o.payment_module_code = 'cod' and o.shipping_module_code = 'table7'");	
$row_count = max($orders_ctt->RecordCount(), $orders_nacex->RecordCount(), $orders_seur->RecordCount());	
	
if($row_count > 0)
{
	$total_ctt = 0.0;
	$total_nacex = 0.0;
	$total_seur = 0.0;
?>
<p class="pageHeading">Daily Report</p>
<table width="900px" cellspacing="0" cellpadding="2" border="1">
	<tr>
		<td colspan="2" width="33%">CTT EXPRESSO</td>
		<td colspan="2" width="33%">NACEX</td>
		<td colspan="2" width="33%">SEUR</td>
	</tr>
	<?php
	for ($i = 0; $i < $row_count; $i++)
	{
		echo("<tr>");
		//show cell of CTT Expresso
		if(!$orders_ctt->EOF)
		{
			$total_ctt += (str_replace('&euro;', '', $orders_ctt->fields['text']));
			echo("<td width='150px'>" . $orders_ctt->fields['orders_id'] . "</td><td width='150px'>" . str_replace('&euro;', '', $orders_ctt->fields['text']) .  "</td>");
			$orders_ctt->MoveNext();
		}
		else echo("<td width='150px'>&nbsp;</td><td width='150px'>&nbsp;</td>");
		
		//show cell of NACEX
		if(!$orders_nacex->EOF)
		{
			$total_nacex += (str_replace('&euro;', '', $orders_nacex->fields['text']));
			echo("<td width='150px'>" . $orders_nacex->fields['orders_id'] . "</td><td width='150px'>" . str_replace('&euro;', '', $orders_nacex->fields['text']) .  "</td>");
			$orders_nacex->MoveNext();
		}
		else echo("<td width='150px'>&nbsp;</td><td width='150px'>&nbsp;</td>");
		//show cell of SEUR
		if(!$orders_seur->EOF)
		{
			$total_seur += (str_replace('&euro;', '', $orders_seur->fields['text']));
			echo("<td width='150px'>" . $orders_seur->fields['orders_id'] . "</td><td width='150px'>" . str_replace('&euro;', '', $orders_seur->fields['text']) .  "</td>");
			$orders_seur->MoveNext();
		}
		else echo("<td width='150px'>&nbsp;</td><td width='150px'>&nbsp;</td>");
		echo("</tr>");
	}
	
	echo ("<tr><td>" . $orders_ctt->RecordCount() . "</td><td>" . $total_ctt . "</td>
	<td>" . $orders_nacex->RecordCount() . "</td><td>" . $total_nacex . "</td>
	<td>" . $orders_seur->RecordCount() . "</td><td>" . $total_seur . "</td></tr>");
			?>
</table>
	<?php 
}
?>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>